package org.example.order.common;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum GoodStatus {
    DISABLE("0", "未上架"),
    ENABLE("1", "已上架");

    @EnumValue
    private final String code;
    private final String desc;

    GoodStatus(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static GoodStatus fromCode(String code) {
        for (GoodStatus status : GoodStatus.values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知商品状态：" + code);
    }


}
